<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>私信消息-农业知识交流论坛</title>
    <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/mycss.css}">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_2080705_jiuqmw0ynch.css">
    <style>
        .chat-list {
            max-height: 600px;
            overflow-y: auto;
        }
        .chat-item {
            padding: 15px;
            border-bottom: 1px solid #eee;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .chat-item:hover {
            background-color: #f8f9fa;
        }
        .chat-item.active {
            background-color: #e9ecef;
        }
        .unread-badge {
            background-color: #dc3545;
            color: white;
            padding: 2px 6px;
            border-radius: 10px;
            font-size: 12px;
        }
    </style>
</head>
<body>
<div th:replace="~{common/header::header}"></div>

<div class="container mt-4">
    <div class="row">
        <div class="col-md-4">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0">聊天列表</h5>
                </div>
                <div class="chat-list">
                    <div th:each="uid : ${chatUsers}" class="chat-item" th:onclick="'window.location.href=\'/chat/' + ${uid} + '\''">
                        <div class="d-flex justify-content-between align-items-center">
                            <div>
                                <img th:src="${@userInfoService.getUserInfoByUid(uid).avatar}" 
                                     class="rounded-circle mr-2" style="width: 40px; height: 40px;">
                                <span th:text="${@userInfoService.getUserInfoByUid(uid).nickname}">用户名</span>
                            </div>
                            <span th:if="${unreadCounts.get(uid) > 0}" 
                                  class="unread-badge" 
                                  th:text="${unreadCounts.get(uid)}">0</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-8">
            <div class="card">
                <div class="card-body text-center">
                    <h5 class="text-muted">选择一个聊天对象开始对话</h5>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:replace="~{common/footer::footer}"></div>

<script th:src="@{/js/jquery-3.5.1.min.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/layui/layui.all.js}"></script>
</body>
</html> 